<template>
  <div id="newsInfo">
      <h4>{{news.title}}</h4>
      <div>{{news.add_time | datefmt('YYYY-MM-DD')}}</div>
      <div v-html="news.content"></div>
      <comment :id="id"></comment>
  </div>
</template>

<script>
import comment from '../comment/comment'
import axios from 'axios'
import common from '../../kits/common.js'
export default {
  name: 'newsinfo',
  data () {
      return {
          id: 0,
          news: ''
      }
  },
  components: {
    comment
  },
  created () {
      //获取路由参数id
      this.id = this.$route.params.id;
      const url = common.apidomain + "/api/getnew/"+ this.id
      //发送请求
      axios.get(url)
      .then(response=>{
          response = response.data;
          this.news = response.message[0]
      })  
  }
}
</script>
<style lang="less" scoped>
    #newsInfo {
        padding: 50px 15px
    }

</style>
